package com.demo2do.fms.entity.authority;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * 用户的供应商权限关系表
 * 
 * @author Ysy
 *
 */
@Entity
@Table(name = "FMS_USER_SUPPLIER_RELATION")
public class UserSupplierRelation {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    /** 用户  */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    private User user;
    
    /** 供应商类型*/
    @Enumerated(EnumType.STRING)
    @Column(name = "SUPPLIER_TYPE")
    private SupplierType type;
    
    /** 供应商ID  */
    private Long supplierId;
    
    /**
     * the default constructor
     */
    public UserSupplierRelation() {
    }
    
    /**
     * 
     * @param user
     * @param type
     * @param supplierId
     */
    public UserSupplierRelation(User user, SupplierType type, Long supplierId) {
        this.user = user;
        this.type = type;
        this.supplierId = supplierId;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }

    /**
     * @return the type
     */
    public SupplierType getType() {
        return type;
    }

    /**
     * @return the supplierId
     */
    public Long getSupplierId() {
        return supplierId;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * @param type the type to set
     */
    public void setType(SupplierType type) {
        this.type = type;
    }

    /**
     * @param supplierId the supplierId to set
     */
    public void setSupplierId(Long supplierId) {
        this.supplierId = supplierId;
    }

}
